package domain

import (
	"net/http"
)

type User struct {
	UUID     string `json:"uuid" gorm:"primaryKey"`
	Name     string `json:"name" validate:"required,name"`
	Password string `json:"password" validate:"required,password"`
	Email    string `json:"email" validate:"email"`
	Created  int64  `json:"create_at" gorm:"autoCreateTime"`
	Updated  int64  `json:"update_at" gorm:"autoUpdateTime"`
}

type UserHandler interface {
	Login(w http.ResponseWriter, r *http.Request)
	Logout(w http.ResponseWriter, r *http.Request)
	Register(w http.ResponseWriter, r *http.Request)
	ResetPassword(w http.ResponseWriter, r *http.Request)
}

type UserService interface {
	LoginAuthByPassword(Username, password string) (*User, error)
	CheckUser(user *User) error
	CreateUser(user *User) error
	CheckUserFields(newUser *User) (*User, error)
	GetUserByName(user *User) (*User, error)
	UpdateUser(user *User) error
}

type UserRepository interface {
	InsertUser(user *User) error
	UpdateUser(user *User) error
	GetUserByName(name string) (*User, error)
	GetUserByEmail(email string) (*User, error)
}
